<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //100.00%
    var reverseStr = function(s, k) {
        if(s.length <= k)return s.split('').reverse().join('');
        let arr = s.split('');
        for(let i=0; i<s.length; i+=2*k){
            let reverse = arr.splice(i,k).reverse();
            arr.splice(i,0,...reverse);
        }
        return arr.join('');
    };
    let s = "abcdefg", k = 2;
    console.log(reverseStr(s, k));
    
</script>
</html>